<!-- +---------------------------------------------------------------------- -->
<!-- | CRMEB [ CRMEB赋能开发者，助力企业发展 ] -->
<!-- +---------------------------------------------------------------------- -->
<!-- | Copyright (c) 2016～2022 https://www.crmeb.com All rights reserved. -->
<!-- +---------------------------------------------------------------------- -->
<!-- | Licensed CRMEB并不是自由软件，未经许可不能去掉CRMEB相关版权 -->
<!-- +---------------------------------------------------------------------- -->
<!-- | Author: CRMEB Team <admin@crmeb.com> -->
<!-- +---------------------------------------------------------------------- -->
{extend name="public/container"}
{block name="title"}一键登录{/block}
{block name="head_top"}
<style>
    .auth-login img {
        display: block;
        width: 6.9rem;
        height: 5.92rem;
        margin: .72rem auto 0;
    }

    .auth-login button {
        display: block;
        width: 6.7rem;
        height: .86rem;
        border-radius: .43rem;
        margin: .56rem auto 0;
        background-color: #2C8EFF;
        font-size: .32rem;
        color: #FFFFFF;
    }

    .auth-login>button:disabled {
        background-color: #A9CEF9;
    }

    .auth-login .tips {
        width: 6.3rem;
        padding: .23rem .25rem .26rem;
        border-radius: .06rem;
        margin: .55rem auto;
        background-color: #FFFAF6;
        font-size: .2rem;
        line-height: .28rem;
        color: #666666;
    }

    .auth-login .tips div:first-child {
        margin-bottom: .11rem;
        text-align: center;
        color: #FF6B00;
    }
</style>
{/block}
{block name="content"}
<div v-cloak id="app" class="auth-login">
    <img src="{__WAP_PATH}zsff/images/auth-login.png" alt="微信一键登录">
    <button :disabled="code" @click="wechat_one_click_login">微信一键登录</button>
    <div class="tips">
        <div>温馨提示：</div>
        <div>点击一键登录按钮，为保证您正常使用系统，我们将获取您的昵称、头像。</div>
    </div>
</div>
{/block}
{block name="foot"}
<script>
    var spread_uid = "{$spread_uid}", appid = "{$appid}", url = encodeURI(window.location.href);
    require(['vue', 'helper', 'store'], function (Vue, $h, store) {
        new Vue({
            el: '#app',
            data: {
                codeUrl: '',
                isfollow: false,
                weixinUrl: 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' + appid + '&redirect_uri=' + url + '&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect',
                code: ''
            },
            created: function () {
                this.go_weixin_check();
            },
            methods: {
                go_weixin_check: function () {
                    this.code = $h.getParmas('code');
                    if (this.code) {
                        store.baseGet($h.U({
                            c: 'login',
                            a: 'weixin_check',
                            p: {spread_uid: spread_uid, code: this.code}
                        }), function (res) {
                            $h.loadClear();
                            layer.msg(res.data.msg, {anim: 0,time:2000}, function () {
                                window.location.assign(localStorage.getItem('wx_login_url') || "{:url('index/index')}");
                            });
                        }, function (err) {
                            $h.loadClear();
                            layer.msg(err, {anim: 0,time:2000}, function () {
                                window.location.replace("{:url('login/index')}");
                            });
                        },true);
                    }
                },
                wechat_one_click_login: function () {
                    $h.loadFFF();
                    window.location.assign(this.weixinUrl);
                }
            }
        })
    })
</script>
{/block}
